<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>浏览器对象模型</title>
	</head>
	<body>
		<a href="#" onclick="goOther()">跳转</a>
		<a href="#" onclick="closeOther()">关闭</a>
		<a href="#" onclick="buy()">我要选英雄</a>
		
		<a href="#" onclick="start()">开始计时</a>
		<a href="#" onclick="stop()">暂停计时</a>
		<a href="#" onclick="reset()">重置计时</a>
		<a href="#" onclick="end()">结束计时</a>
		
	</body>
	<script>
		let otherWinow
		
		let second=0
		
		let myInterval = undefined
		
//		console.writeln('外面')
		function goOther(){
//			alert('hhh')
			otherWinow=window.open('./kt2.html','zy',"width=800,hight=600")
		}
		
		function closeOther(){
			otherWinow.close()
		}
		
		function buy(){
			let name = window.prompt('您好，请问你的名字是：')
			window.alert('欢迎回到王者荣耀，亲爱的召唤师'+name+'!')
			let thing = window.prompt('请您禁用英雄')
			let nums = window.prompt('请选择您的英雄')
			window.alert('欢迎来到王者荣耀！')
			
		}
		
		
		
//		window.onload=function(){
//			setTimeout(function(){
//				document.writeln('我在三秒钟之后执行了')
//			},1000)
			
		function reset(){
			console.log('您已重置，当前时间为：'+ second +'秒')
			second=0
		}
		
		
		function stop(){
			if(myInterval !== undefined){
				clearInterval(myInterval)
				console.log('您已暂停计时，当前时间为：'+ second +'秒')
				myInterval = undefined
			}
		}
		
		
		function start(){
			if(myInterval !== undefined){
				myInterval=setInterval(function(){
					second ++
					console.log('当前到了：'+ second +'秒')
				}.1000)
			}
		}
		
			
			
		}
	</script>
</html>
